package com.iamdigger.queldorei.common.bean;

import java.util.Arrays;

/**
 * 封装 RPC 请求
 *
 * @author Sam Tsai
 * @since 0.1.0
 */
public class RpcRequest {

    private String requestId;
    private String interfaceName;
    private String serviceVersion;
    private String methodName;
    private Class<?>[] parameterTypes;
    private Object[] parameters;

    public String getRequestId() {
        return requestId;
    }

    public void setRequestId(String requestId) {
        this.requestId = requestId;
    }

    public String getInterfaceName() {
        return interfaceName;
    }

    public void setInterfaceName(String className) {
        this.interfaceName = className;
    }

    public String getServiceVersion() {
        return serviceVersion;
    }

    public void setServiceVersion(String serviceVersion) {
        this.serviceVersion = serviceVersion;
    }

    public String getMethodName() {
        return methodName;
    }

    public void setMethodName(String methodName) {
        this.methodName = methodName;
    }

    public Class<?>[] getParameterTypes() {
        return (null != parameterTypes && parameterTypes.length > 0) ?
                Arrays.copyOf(parameterTypes, parameterTypes.length) : null;
    }

    public void setParameterTypes(Class<?>[] parameterTypes) {
        if(null != parameterTypes && parameterTypes.length > 0) {
            this.parameterTypes = Arrays.copyOf(parameterTypes, parameterTypes.length);
        }
    }

    public Object[] getParameters() {
        return (null != parameters && parameters.length > 0) ?
                Arrays.copyOf(parameters, parameters.length) : null;
    }

    public void setParameters(Object[] parameters) {
        if(null != parameters && parameters.length > 0) {
            this.parameters = Arrays.copyOf(parameters, parameters.length);
        }
    }
}
